#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

void test_getWinners()
{
	int players[MAX_PLAYERS];
	int expected_scores[MAX_PLAYERS] = { 18, 13, 16, 0 };

	struct gameState state;

	/* Test One: Three players, no gardens, normal conditions */
	state.numPlayers = 3;
	state.handCount[players[0]] = 6;

	// Expected Score: 18
	state.hand[players[0]][0] = estate;
	state.hand[players[0]][1] = estate;
	state.hand[players[0]][2] = duchy;
	state.hand[players[0]][2] = province;
	state.hand[players[0]][2] = great_hall;
	state.hand[players[0]][2] = province;

	// Expected Score: 13
	state.hand[players[1]][0] = estate;
	state.hand[players[1]][1] = estate;
	state.hand[players[1]][2] = duchy;
	state.hand[players[1]][2] = province;
	state.hand[players[1]][2] = great_hall;
	state.hand[players[1]][2] = estate;

	// Expected Score: 16
	state.hand[players[2]][0] = curse;
	state.hand[players[2]][1] = estate;
	state.hand[players[2]][2] = duchy;
	state.hand[players[2]][2] = province;
	state.hand[players[2]][2] = great_hall;
	state.hand[players[2]][2] = estate;

	getWinners(players, &state);

	if (players[0] == 1) {
		if (players[1] == 1) {
			printf("Test One: FAILED - player 2 falsely computed as winner\n");
		}
		else if (players[2] == 1) {
			printf("Test One: FAILED - players 3 falsely computed as winner\n");
		}
		else
		{
			printf("Test One: PASS\n");
		}
	}
	else {
		printf("Test One: FAILED - expected winner not computed\n");
	}
}

int main(void)
{
	test_getWinners();
	return EXIT_SUCCESS;
}